home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 9.8 KB | 351 lines | [TEXT/MPS ] |
-
- //========================================================================================
- //
- // File: FWSemPrt.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWPRTSCP_H
- #include "FWPrtScp.h"
- #endif
-
- // ----- Framework Includes -----
-
- #ifndef FWPART_H
- #include "FWPart.h"
- #endif
-
- #ifndef FWDESC_H
- #include "FWDesc.h"
- #endif
-
- #ifndef FWDSCOPR_H
- #include "FWDscOpr.h"
- #endif
-
- #ifndef FWFRAME_H
- #include "FWFrame.h"
- #endif
-
- #ifndef FWOBJSPC_H
- #include "FWObjSpc.h"
- #endif
-
- #ifndef FWPRTITE_H
- #include "FWPrtIte.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWPSTR_H
- #include "FWPStr.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_ODRegistry_defined
- #include <ODRgstry.xh>
- #endif
-
- #ifndef SOM_ODObjectSpec_xh
- #include <ODObjSpc.xh>
- #endif
-
- // ----- Macintosh Includes -----
-
- #ifndef __AEOBJECTS__
- #include <AEObjects.h>
- #endif
-
- #ifndef __AEPACKOBJECT__
- #include <AEPackObject.h>
- #endif
-
- //========================================================================================
- // Runtime Information
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwsemevt
- #endif
-
- FW_DEFINE_AUTO(FW_MPartScriptable)
- FW_DEFINE_AUTO(FW_MEmbeddingPartScriptable)
-
- //========================================================================================
- // class FW_MPartScriptable
- //========================================================================================
-
- FW_DEFINE_CLASS_M1(FW_MPartScriptable, FW_MScriptable)
-
- //---------------------------------------------------------------------------------------
- // FW_MPartScriptable::FW_MPartScriptable
- //---------------------------------------------------------------------------------------
-
- FW_MPartScriptable::FW_MPartScriptable() :
- FW_MScriptable()
- {
- FW_END_CONSTRUCTOR
- }
-
- //---------------------------------------------------------------------------------------
- // FW_MPartScriptable::~FW_MPartScriptable
- //---------------------------------------------------------------------------------------
-
- FW_MPartScriptable::~FW_MPartScriptable()
- {
- FW_START_DESTRUCTOR
- }
-
- //---------------------------------------------------------------------------------------
- // FW_MPartScriptable::GetObjectClass
- //---------------------------------------------------------------------------------------
-
- ODDescType FW_MPartScriptable::GetObjectClass() const
- {
- return cPart;
- };
-
- //---------------------------------------------------------------------------------------
- // FW_MPartScriptable::GetSpecifierForm
- //---------------------------------------------------------------------------------------
-
- ODDescType FW_MPartScriptable::GetSpecifierForm() const
- {
- return formUniqueID;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_MPartScriptable::EmbeddedFrameSpec
- //---------------------------------------------------------------------------------------
-
- void FW_MPartScriptable::EmbeddedFrameSpec(Environment* ev,
- FW_CPart* part,
- FW_CFrame* embeddedFrame,
- FW_CDesc& objectSpec)
- {
- FW_CAcquiredODFrame aqContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
- if (aqContainingFrame != NULL)
- {
- FW_CDesc containerSpec;
-
- FW_CAcquiredODPart aqContainingPart = aqContainingFrame->AcquirePart(ev);
- aqContainingPart->EmbeddedFrameSpec(ev, aqContainingFrame, containerSpec);
-
- FW_CPartFrameIterator iter(ev, part);
- FW_CDesc mySpecData;
-
- FW_Boolean gotData = FALSE;
-
- long index = 1;
-
- for (FW_CFrame* frame = iter.First(ev); iter.IsNotComplete(ev) && !gotData; iter.Next(ev), index++)
- {
- if (frame == embeddedFrame)
- {
- mySpecData << index;
- gotData = TRUE;
- }
- }
-
- if (gotData)
- ::FW_CreateObjSpecifier(cPart, containerSpec, formAbsolutePosition, mySpecData, objectSpec);
- else
- FW_Failure(kODErrCannotEmbed);
- }
- else
- objectSpec.Clear();
- }
-
- //---------------------------------------------------------------------------------------
- // FW_MPartScriptable::AcquireContainingObject
- //---------------------------------------------------------------------------------------
-
- FW_MScriptable* FW_MPartScriptable::AcquireContainingObject(Environment* ev,
- FW_CPart* part) const
- {
- FW_UNUSED(ev);
- FW_UNUSED(part);
- FW_Failure(errAEEventNotHandled);
- return NULL; // return statement to satisfy compiler
- }
-
- //---------------------------------------------------------------------------------------
- // FW_MPartScriptable::AcquireObjectContainedInPart
- //---------------------------------------------------------------------------------------
-
- FW_MScriptable* FW_MPartScriptable::AcquireObjectContainedInPart(Environment* ev,
- ODDescType desiredClass,
- ODDescType form,
- FW_CDesc& selectionData)
- {
- FW_UNUSED(ev);
- FW_UNUSED(desiredClass);
- FW_UNUSED(form);
- FW_UNUSED(selectionData);
- return NULL;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_MPartScriptable::CountElementsInPart
- //---------------------------------------------------------------------------------------
-
- long FW_MPartScriptable::CountElementsInPart(Environment* ev,
- ODDescType desiredClass)
- {
- FW_UNUSED(ev);
- FW_UNUSED(desiredClass);
- FW_Failure(errAEEventNotHandled);
- return 0; // return statement to satisfy compiler
- }
-
- //---------------------------------------------------------------------------------------
- // FW_MPartScriptable::BuildObjectSpecifier
- //---------------------------------------------------------------------------------------
-
- void FW_MPartScriptable::BuildObjectSpecifier(Environment* ev,
- FW_CPart* part,
- const FW_CFrame* frame,
- FW_CDesc& specifier,
- ODDescType preferredForm) const
- {
- volatile FW_Boolean gotFrameSpec = FALSE;
-
- FW_TRY
- {
- ODPart* odPart = part->GetODPart(ev);
- odPart->EmbeddedFrameSpec(ev, frame->GetODFrame(ev), specifier);
-
- gotFrameSpec = TRUE;
- }
- FW_CATCH_BEGIN
- FW_CATCH_EVERYTHING()
- {
- gotFrameSpec = FALSE;
- }
- FW_CATCH_END
-
- if (!gotFrameSpec)
- {
- if (preferredForm == formUniqueID)
- {
- FW_CDesc nullDesc;
- FW_CDesc mySpecifier;
-
- ODPersistentObjectID id = part->GetDraft(ev)->GetPersistentObjectID(ev, frame->GetODFrame(ev), kODFrameObject);
- mySpecifier.PutLongInteger(id);
-
- ::FW_CreateObjSpecifier(GetObjectClass(), nullDesc, preferredForm, mySpecifier, specifier);
- }
- else
- FW_Failure(errAECantSupplyType);
- }
- }
-
- //---------------------------------------------------------------------------------------
- // FW_MPartScriptable::HasProperty
- //---------------------------------------------------------------------------------------
-
- FW_Boolean FW_MPartScriptable::HasProperty(ODDescType whichProperty) const
- {
- return (whichProperty == pUniqueID);
- }
-
- //---------------------------------------------------------------------------------------
- // FW_MPartScriptable::GetProperty
- //---------------------------------------------------------------------------------------
-
- FW_Boolean FW_MPartScriptable::GetProperty(Environment* ev,
- FW_CPart* part,
- FW_CDesc& propertyValue,
- ODDescType whichProperty,
- ODDescType desiredType) const
- {
- FW_UNUSED(desiredType);
- if (whichProperty == pUniqueID)
- {
- // the part is being asked to provide a uniqueID, but there is no way
- // to associate the id with any frame other than the last active frame.
- // It is possible to get a persistent ID for the kODPartObject, but
- // OpenDoc doesn't expect persistent part ID's when resolving object
- // specifiers.
-
- ODFrame* frame = part->GetLastActiveFrame(ev)->GetODFrame(ev);
- ODPersistentObjectID id = part->GetDraft(ev)->GetPersistentObjectID(ev,frame, kODFrameObject);
-
- propertyValue.PutLongInteger(id);
-
- return TRUE;
- }
- else
- return FALSE;
- }
-
- //---------------------------------------------------------------------------------------
- // FW_MPartScriptable::EmbeddedFrameSpecGlue
- //---------------------------------------------------------------------------------------
-
- void FW_MPartScriptable::EmbeddedFrameSpecGlue(Environment* ev,
- FW_CPart* part,
- ODFrame* embeddedFrame,
- ODObjectSpec* spec)
- {
- FW_TRY
- {
- FW_MPartScriptable* semanticPart = FW_DYNAMIC_CAST(FW_MPartScriptable, part);
-
- if (semanticPart)
- {
- FW_CDesc objectSpec(spec);
- FW_CFrame* embeddedFWFrame = FW_CFrame::ODtoFWFrame(ev, embeddedFrame);
-
- semanticPart->EmbeddedFrameSpec(ev, part, embeddedFWFrame, objectSpec);
- }
- else
- FW_SetEvError(ev, kODErrCannotEmbed);
- }
- FW_CATCH_BEGIN
- FW_CATCH_REFERENCE(FW_XException, exception)
- {
- // kODErrCannotEmbed
- FW_SetException(ev, exception);
- }
- #ifdef FW_DEBUG
- FW_CATCH_EVERYTHING()
- {
- // FW_DEBUG_MESSAGE(FW_kInvalidException);
- FW_SetEvError(ev, kODErrUndefined);
- }
- #endif
- FW_CATCH_END
- }
- //========================================================================================
- // class FW_MEmbeddingPartScriptable
- //========================================================================================
-
- FW_DEFINE_CLASS_M1(FW_MEmbeddingPartScriptable, FW_MPartScriptable);
-
- //---------------------------------------------------------------------------------------
- // FW_MEmbeddingPartScriptable::FW_MEmbeddingPartScriptable
- //---------------------------------------------------------------------------------------
-
- FW_MEmbeddingPartScriptable::FW_MEmbeddingPartScriptable() :
- FW_MPartScriptable()
- {
- FW_END_CONSTRUCTOR
- }
-
- //---------------------------------------------------------------------------------------
- // FW_MEmbeddingPartScriptable::~FW_MEmbeddingPartScriptable
- //---------------------------------------------------------------------------------------
-
- FW_MEmbeddingPartScriptable::~FW_MEmbeddingPartScriptable()
- {
- FW_START_DESTRUCTOR
- }
-
-
-